package pool

import "sync"


var(
	globalPolls *pools = &pools{cache: make(map[string]Pool)}
)

type pools struct {
	mux sync.Mutex
	cache map[string]Pool
}

//add pool with pool name
func (this *pools) add (name string, p Pool) (added bool){
	this.mux.Lock()
	defer this.mux.Unlock()
	if _, ok := this.cache[name]; !ok {
		this.cache[name] = p
		added = true
	}
	return
}

func (this *pools) get (name string) (p Pool, ok bool) {
	this.mux.Lock()
	defer this.mux.Unlock()
	p , ok = this.cache[name]
	return
}